﻿/*
 *  DFUtil - a utility for creating and implementing blueprints in Dwarf Fortress.
 *  
 *  Copyright (C) 2009  Katharine Gillis
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/.
*/

using System;
using System.Drawing;

namespace DFUtil
{
    /// <summary>
    /// Stores information about a designation, building, stockpile, or query.
    /// </summary>
    public class Item : IComparable<Item>
    {


        #region Properties

        private Point _point;
        /// <summary>
        /// Gets the top left corner in grid units.
        /// </summary>
        public Point Point
        {
            get { return _point; }
        }

        private Size _size;
        /// <summary>
        /// Gets the size in grid units.
        /// </summary>
        public Size Size
        {
            get { return _size; }
        }

        private string _type;
        /// <summary>
        /// Gets the type of item ('d' for a digging designation, etc).
        /// </summary>
        public String Type
        {
            get { return _type; }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Creates the Item object, using the given top left corner (Point) and size (both in grid units), and the type.
        /// </summary>
        /// <param name="point">Top left corner</param>
        /// <param name="size">Size</param>
        /// <param name="type">Type</param>
        public Item(Point point, Size size, string type)
        {
            _point = point;
            _size = size;
            _type = type;
        }

        public Item() { }

        #endregion

        #region IComparable<DFItem> Members

        /// <summary>
        /// Compares the top left point of each DFItem, ordering first by the Y coordinate, then by the X.
        /// </summary>
        /// <param name="other">DFItem to compare to.</param>
        /// <returns>Less than zero if this item is less than the other, zero if they are equal, and greater
        /// than zero if it is greater than the other.</returns>
        public int CompareTo(Item other)
        {
            if (_point.Y != other.Point.Y)
                return _point.Y - other.Point.Y;
            else
                return _point.X - other.Point.X;
        }

        #endregion
    }
}
